package com.mnsq.im.conf;

import com.mnsq.im.business.TkInboundInfo;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.stream.ChunkedWriteHandler;

/**
 * @author zj00924
 */
public class InitChannelHandler extends ChannelInitializer {
    @Override
    protected void initChannel(Channel channel) {
        channel.pipeline().addLast("http-codec", new HttpServerCodec())
                // HttpObjectAggregator：将HTTP消息的多个部分合成一条完整的HTTP消息
                .addLast("aggregator", new HttpObjectAggregator(65535))
                // ChunkedWriteHandler：向客户端发送HTML5文件
                .addLast("http-chunked", new ChunkedWriteHandler())
                // 在管道中添加我们自己的接收数据实现方法
                .addLast("handler", new TkInboundInfo());
    }
}
